package top.college.screen;

import java.util.List;

import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

import top.college.model.AdminVO;
import top.college.service.AdminRead;
import top.college.swing.AdminSelect;

public class AdminSelectTable {
	private static int part;

	public static DefaultTableModel adminSelectTable() {
		final DefaultTableModel dtm = new DefaultTableModel() {
			@Override
			public boolean isCellEditable(int row, int column) {
				return false;
			}
		};
		
		String title[] = { "순번", "ID", "이름", "연락처", "등록일자" };
		dtm.setColumnIdentifiers(title);
		
		int count = 1;
		for(AdminVO vo : AdminRead.readAdmin() ){
			vo.getAdmin_id();
			dtm.addRow( new String[] { Integer.toString(count), vo.getAdmin_id(), vo.getAdmin_name(),
					vo.getAdmin_tel(), vo.getReg_date() });
			++ count;
		}
		return dtm;
	}
	
	public static DefaultTableModel adminSelectTable(JTextField Pass) {
		part = AdminSelect.part;
		final DefaultTableModel dtm = new DefaultTableModel() {
			@Override
			public boolean isCellEditable(int row, int column) {
				return false;
			}
		};
			
		String title[] = { "순번", "ID", "이름", "연락처", "등록일자" };
		dtm.setColumnIdentifiers(title);
			
		switch ( part ) {
		case 1 :
			int count = 1;
			for(AdminVO vo : AdminRead.readAdminName(Pass) ){
				vo.getAdmin_id();
				dtm.addRow( new String[] { Integer.toString(count), vo.getAdmin_id(), vo.getAdmin_name(),
						vo.getAdmin_tel(), vo.getReg_date() });
				++ count;
			}
			return dtm;
		case 2 :
			count = 1;
			for(AdminVO vo : AdminRead.readAdminId(Pass) ){
				vo.getAdmin_id();
				dtm.addRow( new String[] { Integer.toString(count), vo.getAdmin_id(), vo.getAdmin_name(),
						vo.getAdmin_tel(), vo.getReg_date() });
				++ count;
			}
			return dtm;
		}
		return null;
	}
}